//
//  CKTool.swift
//  CKBasic
//
//  Created by 纪洪波 on 2017/9/5.
//  Copyright © 2017年 Zac. All rights reserved.
//

import UIKit

public struct CKBasic {
    static var adView: CKADView = {
        let view = Bundle.main.loadNibNamed("CKADView", owner: nil, options: nil)?.first as! CKADView
        view.frame = CGRect(x: 0, y: 0, width: KscreenWidht, height: KscreenHeight)
        return view
    }()
    
    static var lineView: CKLine = {
        let view = Bundle.main.loadNibNamed("CKLine", owner: nil, options: nil)?.first as! CKLine
        return view
    }()
    
    public static func jump() {
        guard let url = URL(string: "http://qianka.com/") else {
            return
        }

        if #available(iOS 10.0, *) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }else {
            UIApplication.shared.openURL(url)
        }
    }
    
    public static func showAD() {
        if let windows = UIApplication.shared.delegate?.window {
            windows?.addSubview(adView)
        }
        adView.showAD()
    }
    
    public static func addLineView(frame: CGRect, clickBlock:@escaping (() -> Void)) {
        lineView.frame = frame
        if let windows = UIApplication.shared.delegate?.window {
            windows?.addSubview(lineView)
        }
        
        lineView.clickBlock = clickBlock
    }
}
